
import buyVipPopup from "./buyVipPopup.vue";
import {
  isZsjxApp,
  OSType
} from "@/common/utils.js";
export default {
  install(Vue){
    // 成为vue子类
    const PopVipRuctor = Vue.extend(buyVipPopup);
    // 子类实例
    let instance = new PopVipRuctor(Vue);
    // 挂载
    instance.$mount(document.createElement('div'));
    document.body.appendChild(instance.$el);

    Vue.prototype.$popVip = (pms)=>{
      if(pms.show && isZsjxApp){ //如果在客户端内打开，则调用客户端的弹框
        // alert('弹框挂载对象：'+JSON.stringify(window.appBridgeObj));
        // alert(window.webkit);
        // alert('直接调用：'+window.showVipPop);
        // window.showVipPop('1');
        // window.appBridgeObj.showVipPop(JSON.stringify(pms.minLeve));
        if(OSType == 'ios'){  //调用ios弹框方法
          window.webkit.messageHandlers.showVipPop.postMessage(JSON.stringify(pms.minLeve));
        }else{ //调用安卓弹框方法
          window.appBridgeObj.showVipPop(JSON.stringify(pms.minLeve));
        }
      }else{
        instance.show = pms.show;
        if(pms){
          instance.close = pms.close;
          instance.open = pms.open;
          instance.minLeve = pms.minLeve;
          instance.obj = pms.obj;
        }
      }
    }
    Vue.component("buyVipPopup", buyVipPopup);
  }
}
